<?php
/**
 * Created by PhpStorm.
 * User: ybjaa
 * Date: 2017/5/24
 * Time: 16:11
 */

namespace App\Business;


class ReturnResult
{

    public static function Success($data=null,$message=null)
    {

        $result = new ReturnResult();
        $result->result = true;
        $result->data = $data;
        $result->message = $message;

        return $result;
    }


    public static function Error($data=null,$message=null)
    {

        $result=new ReturnResult();
        $result->result=false;
        $result->data=$data;
        $result->message=$message;

        return $result;

    }

    public static function ParameterError($data=null,$message="参数错误")
    {

        $result=new ReturnResult();
        $result->result=false;
        $result->data=$data;
        $result->message=$message;

        return $result;

    }


    /**
     * @param $result
     * @param null $data 数据
     * @param null $message 字符
     * @return ReturnResult
     */
    public static function DefineResult($result, $data=null, $message=null)
    {

        $returnResult=new ReturnResult();
        $returnResult->result=$result;
        $returnResult->data=$data;
        $returnResult->message=$message;

        return $returnResult;

    }


    public $result;
    public $data;
    public $message;

    public function ToJson()
    {
        return json_encode($this);
    }











}